<?php
	defined ('CELL_INDEX') or die ('access denied');
	if (isset ($_POST ['delete']) and count ($_POST ['delete'])) {
		$Users = "'".implode ("','", array_keys ($_POST ['delete']))."'";
		$Result = pg_affected_rows (pg_query ("delete from \"Users\" where \"Username\" in ($Users);"));
		LeaveMessage ("Deleted $Result users.");
		ViewSuggest ('users');
	}
	if (isset ($_POST ['new-username']) and isset ($_POST ['new-number'])) {
		$Username = $_POST ['new-username'];
		$Number = $_POST ['new-number'];
		if ($Result = pg_affected_rows (pg_query ("insert into \"Users\" values ('$Username', $Number);"))) {
			$Message = "User $Username added successfully.";
		} else {
			if ($Error = pg_last_error ()) {
				$Message = "User $Username was not added: $Error";
			} else $Message = "User $Username was not added (and there was no error message)";
		}
		LeaveMessage ($Message);
		ViewSuggest ('users');
	}
?>